require 'View/UIBase/UIBase'

UIStoryInfo = UIBase.New(PanelResNames.UIStoryInfo)
local _UIStoryInfo = UIStoryInfo

function _UIStoryInfo.Init()
    UIBase.Init(_UIStoryInfo)
end

-- 创建回调
function _UIStoryInfo:OnCreate()
    self.bgClose = self:GetChild("bgClose")
    self.title = self:GetChild("title")
    self.desc = self:GetChild("desc")
    self.lockTips = self:GetChild("lockTips")
    self:RegisterOnClick(self.bgClose,self.OnBack)
    self.funData = G.dataTable["t_functionswitch"][tostring(Config.FuncOpenType.StoryModelReward)]
    self.title.text = getLanguage("HelpTitle2100")
    self.desc.text = getLanguage(tostring(self.funData.f_FunctionOpenDes))
end

-- 显示
function _UIStoryInfo:OnEnable()
    local isStage = logicMgr.FuncOpenManager.unlock_check2(self.funData)
    local isTime, time = logicMgr.FuncOpenManager.unlock_check6(self.funData)
    local stageStr = G.dataTable["t_stagehardmode"][tostring(self.funData.f_UnlockStage)].f_StageName
    if not isStage and not isTime then
        self.lockTips.text =string.format(getLanguage("TaskInfo_FunctionOpen_StateLocked3"), getLanguage(stageStr), math.ceil(time / (3600 * 24)))
    elseif not isStage then
        self.lockTips.text =string.format(getLanguage("TaskInfo_FunctionOpen_StateLocked"), getLanguage(stageStr));
    elseif not isTime then
        self.lockTips.text =string.format(getLanguage("TaskInfo_FunctionOpen_StateLocked2"), math.ceil(time / (3600 * 24)));
    else
        self.lockTips.text = ""
    end
   FireEvent(Config.EventType.HardStoryOpen)
end

-- 关闭
function _UIStoryInfo:OnClose()

end

-- 隐藏
function _UIStoryInfo:OnDisable()
end

-- 卸载
function _UIStoryInfo:OnDestroy()

end

return _UIStoryInfo